import { createRouter, createWebHistory } from 'vue-router'

const router = createRouter({
  history: createWebHistory(import.meta.env.BASE_URL),
  routes: [
    {
      path: '/',
      redirect: '/home'
    },
    {
      path: '/home',
      name: 'home',
      meta: {
        isShow: false,
        tital: '主页'
      },
      component: () => import('../views/Home.vue'),
      redirect: '/home/wall',
      children: [
        {
          path: 'wall',
          name: 'wall',
          meta: {
            isShow: false,
            tital: '真.主页'
          },
          component: () => import('../views/MessageWall.vue')
        }
      ]

    }
  ]
})

router.afterEach((to, from) => {
  if (to.meta.tital) {
    document.title = to.meta.tital as string
  } else {
    document.title = '留言墙'
  }
})

export default router